package com.example.testdemo.designModel;

/**
 * 单例模式------懒汉式    线程不安全
 */
public class SinglonTwo {

    public  static  SinglonTwo  instance;

    public  SinglonTwo(){
        System.out.println("========构造方法");
    }

    public  static  SinglonTwo getInstance(){
//         instance =new SinglonTwo();
         return  instance==null?new SinglonTwo():instance;
    }
}

class  TestDemoSingle{
    public static void main(String[] args) {
         SinglonTwo s1=SinglonTwo.getInstance();
         SinglonTwo s2=SinglonTwo.getInstance();

        System.out.println(s1==s2);
    }
}
